import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
  AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  })],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
    }
  },
  server:{
    proxy:{
      "/m.api": {
        // 代理api
        target: "http://192.168.1.188:8080", // 服务器api地址
        changeOrigin: true, // 是否跨域
      },
      "/upload/admin": {
        // 代理api
        target: "http://192.168.1.188:8080", 
        changeOrigin: true, // 是否跨域
      }
    }
  }
})
